# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.spark_submit import SparkSubmitOperator

from jms.dwd.dwd_terminal_sign_detail_dt import jms_dwd__dwd_terminal_sign_detail_dt


jms_dws__dws_system_unfinished_summary_dt = SparkSubmitOperator(
    task_id='jms_dws__dws_system_unfinished_summary_dt',
    email=['houwenlong@jtexpress.com','yl_bigdata@yl-scm.com'],
    pool_slots=4,
    # depends_on_past=True,  # 如果任务依赖于前一天的同名任务，则将 depends_on_past 设为 True
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='jms_dws__dws_system_unfinished_summary_dt_{{ execution_date | date_add(1) | cst_ds }}',  # yarn 任务名称
    driver_memory='8G',
    driver_cores=2,
    executor_memory='8G',
    executor_cores=4,
    num_executors=20,
    conf={'spark.sql.shuffle.partitions': 600,
          'spark.executor.memoryOverhead': 2048,
          'spark.core.connection.ack.wait.timeout': 300,
          'spark.default.parallelism': 600,
          'spark.locality.wait': 60,
          },
    jars='hdfs:///scheduler/jms/spark/chk/report/system_unfinished_summary_data/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.report.SystemUnfinishedSummaryData',  # spark 主类
    application='hdfs:///scheduler/jms/spark/chk/report/system_unfinished_summary_data/original-jobs-1.0-SNAPSHOT.jar',
    # spark jar 包
    application_args=['{{ execution_date | date_add(1) | cst_ds }}'],  # 参数dt 运行当天日期
    execution_timeout=timedelta(hours=7),
)

# 设置依赖
jms_dws__dws_system_unfinished_summary_dt << [
    jms_dwd__dwd_terminal_sign_detail_dt
]
